﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Genesis
{
    public partial class frmEdit : Form
    {
        public frmEdit()
        {
            InitializeComponent();
        }

        private void frmEdit_Load(object sender, EventArgs e)
        {
            if (this.Text == "Edit Title")
            {
                this.Text = "Edit";
                lblEdit.Text = "Title";
                txtEdit.Text = Library.CurrentSong.Title;
            }
            else if (this.Text == "Edit Artist")
            {
                this.Text = "Edit";
                lblEdit.Text = "Artist";
                txtEdit.Text = Library.CurrentSong.Artist;
            }
            else if (this.Text == "Edit Album")
            {
                this.Text = "Edit";
                lblEdit.Text = "Album";
                txtEdit.Text = Library.CurrentSong.Album;
            }
            else if (this.Text == "Edit Genre")
            {
                this.Text = "Edit";
                lblEdit.Text = "Genre";
                txtEdit.Text = Library.CurrentSong.Genre;
            }
        }
        private void frmEdit_Closing(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Abort;
        }
        private void cmdEdit_Click(object sender, EventArgs e)
        {
            if (lblEdit.Text == "Title")
                Library.CurrentSong.Title = txtEdit.Text;
            else if (lblEdit.Text == "Artist")
                Library.CurrentSong.Artist = txtEdit.Text;
            else if (lblEdit.Text == "Album")
                Library.CurrentSong.Album = txtEdit.Text;
            else if (lblEdit.Text == "Genre")
                Library.CurrentSong.Genre = txtEdit.Text;

            Library.UpdateSong(Library.CurrentSong);
            this.DialogResult = DialogResult.OK;
        }
        private void cmdCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
        }
        private void txtEdit_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Enter)
            {
                e.Handled = true;
                cmdEdit_Click(null, null);
            }
        }

    }
}
